package org.blogwu.learn.threadLearn.CopyOnWriteArrayList;

import org.apache.commons.lang3.StringUtils;

import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.LinkedBlockingQueue;

public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        // 读写分离List
//        CopyOnWriteArrayList<String> copyOnWriteArrayList = new CopyOnWriteArrayList();
//        copyOnWriteArrayList.add("1");
//        copyOnWriteArrayList.add("2");
//        copyOnWriteArrayList.add("3");
//        copyOnWriteArrayList.add("4");
//        copyOnWriteArrayList.add("5");

        // 阻塞对列
        LinkedBlockingQueue<String> blockingQueue = new LinkedBlockingQueue<>();
        blockingQueue.put("1");

        System.out.println(blockingQueue.take());
//        new Thread(() -> {
//            for (Iterator<String> it = copyOnWriteArrayList.iterator(); it.hasNext(); ) {
//                try {
//                    Thread.sleep(500);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//                System.out.println(it.next());
//            }
//
//        }).start();
//        try {
//            Thread.sleep(1000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        new Thread(() -> {
//            copyOnWriteArrayList.remove(1);
//        }).start();

//        String buildM3U8PlayUrl = "httpss://push.duizhuang.com/duizhuang_hd/pcMZsDJyGb6eFAlyNJZc71_ud.m3u8?auth_key=1580872656-0-0-4c85c64f2b3df92fef81b2db8b80672c";
//         if (StringUtils.isNotBlank(buildM3U8PlayUrl) ) {
//            buildM3U8PlayUrl = buildM3U8PlayUrl.replace("http://", "https://");
//         }
//        System.out.println(buildM3U8PlayUrl);

//        System.out.println(16 - (16 >>> 2));

//        Iterator<String> copI = copyOnWriteArrayList.iterator();
//        while (copI.hasNext()){
//           String s = copI.next();
//           if (s.equals("3")){
//                copI.remove();
//                continue;
//           }
//            System.out.println(s);
//        }
    }
}
